<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link rel='stylesheet' type='text/css' href='/static/view/css/head.css'>
		<link rel='stylesheet' type='text/css' href='/static/view/css/common.css'>
                <link rel='stylesheet' type='text/css' href='/static/view/css/forumDetail.css'>
                <style type="text/css">.test{border: 1px solid red;}</style>
                <script type='text/javascript' src='/static/ckeditor/ckeditor.js'></script>
		<title>论坛</title>
	</head>
	<body>
		<include file="public:header"/>
                <p style="font-size:12px;margin: 0px auto 10px 15px;"><a href="/User/forum/forum">论坛</a> &gt; <a href="/User/forum/forumDetail?id={$forum['id']}">{$forum['parent_forum_name']}</a> &gt; <a href="/User/forum/forumDetail?id={$forum['id']}">{$forum['forum_name']}</a></p>
                <div class="container">
                    
                    <include file="public:leftbar"/>
                    
                    <div class="overview">
                        <b>{$forum['forum_name']}</b> 精华帖: {$forum['good_posts_count']}|主题: {$forum['theme_count']}
                    </div>
                    <div class="posts-btn"><a href="#posts"><button>发帖</button></a></div>
                    <div class="childFurom">
                        <h3>帖子列表</h3>
                        <empty name="list"><h2 style="color:orange;line-height: 2.5;">该版块还是一片净土,欢迎您开垦这片肥沃的土地！！！</h2><else/>
                            <table border="0px" cellspacing="0" width="1000px" height="200px">
                                <tr><th>ID</th><th>主题</th><th>是否精华帖</th><th>作者</th><th>发表日期</th></tr>
                                <volist name="list" id="list">
                                    <tr align="center"><td>{$list.id}</td><td><a href="/User/posts/postsDetail?posts_id={$list.id}&author_id={$list.author_id}&forum_id={$forum['id']}">{$list.theme}</a></td>
                                        <td><if condition="$list.is_good eq 'yes'"><h4 style="color:orange;">精华帖</h4><else/>普通帖</if></td>
                                        <td>{$list.author}</td><td>{$list.dateline}</td>
                                    </tr>
                                </volist>
                            </table>
                        </empty>
                        {$page}
                    </div>
                    <div class="postsPublish"><a name="posts"></a><!--锚点-->
                         <form action="/User/posts/postsPublish" method="post" id="posts-submit">
                                <h3>快速发帖</h3><br/>
                                <input id="theme" name="theme" type="text" required autocomplete="on" placeholder="帖子主题" size="50" style="height: 32px;border: 1px solid #BDD7E3" autocomplete="on" x-webkit-speech speech/><label for="theme">标题栏</label>
                                <input type="button" id="btn_h_type" value="高级模式">
                                <input type="button" id="btn_l_type" value="普通模式" style="display: none">
                                <div style="margin-top:10px;">
                                    <input name="mood" type="radio" value="/static/view/image/mood/001.gif"><img src="/static/view/image/mood/001.gif">
                                    <input name="mood" type="radio" value="/static/view/image/mood/002.gif"><img src="/static/view/image/mood/002.gif">
                                    <input name="mood" type="radio" value="/static/view/image/mood/003.gif"><img src="/static/view/image/mood/003.gif">
                                    <input name="mood" type="radio" value="/static/view/image/mood/004.gif"><img src="/static/view/image/mood/004.gif">
                                    <input name="mood" type="radio" value="/static/view/image/mood/005.gif"><img src="/static/view/image/mood/005.gif">
                                    <input name="mood" type="radio" value="/static/view/image/mood/006.gif"><img src="/static/view/image/mood/006.gif">
                                    <input name="mood" type="radio" value="/static/view/image/mood/007.gif"><img src="/static/view/image/mood/007.gif">
                                    <input name="mood" type="radio" value="/static/view/image/mood/008.gif"><img src="/static/view/image/mood/008.gif">
                                    <input name="mood" type="radio" value="/static/view/image/mood/009.gif"><img src="/static/view/image/mood/009.gif">
                                    <input name="mood" type="radio" value="/static/view/image/mood/010.gif"><img src="/static/view/image/mood/010.gif">
                                    <input name="mood" type="radio" value="/static/view/image/mood/011.gif"><img src="/static/view/image/mood/011.gif">
                                    <input name="mood" type="radio" value="/static/view/image/mood/012.gif"><img src="/static/view/image/mood/012.gif">
                                    <input name="mood" type="radio" value="/static/view/image/mood/013.gif"><img src="/static/view/image/mood/013.gif">
                                </div>

                                    <input name="forum_id" type="hidden" value="{$forum['id']}"/>
                                    <input name="posts_id" type="hidden" value="{$forum['id']}"/>
                                    <input name="forum_name" type="hidden" value="{$forum['forum_name']}"/>
                                    <input name="url" type="hidden" value="/User/forum/forumDetail?id={$forum['id']}"/>
                                    <span id="btn">
                                    <input name="" type="button" value="h1" id="h1" class="btn" title="1号标题"/>
                                    <input name="" type="button" value="h2" id="h2" class="btn" title="2号标题"/>
                                    <input name="" type="button" value="h3" id="h3" class="btn" title="3号标题"/>
                                    <input name="" type="button" value="h4" id="h4" class="btn" title="4号标题"/>
                                    <input name="" type="button" value="h5" id="h5" class="btn" title="5号标题"/>
                                    <input name="" type="button" value="b" id="bold" class="btn" title="粗体"/>
                                    <input name="" type="button" value="i" id="italics" class="btn" title="斜体"/>
                                    <input name="" type="button" value="u" id="underline" class="btn" title="下划线"/>
                                     <!--<button type="button" id="apply" class="btn-mini">apply</button>-->
                                     </span>
                                <p>
                                    <textarea id="selectable" name="content" rows="8" cols="85" style="border:1px solid #BDD7E3"/>
                                    </textarea>
                                </p>
                                <p id="container"></p>
                                <php>if(!empty($_SESSION['userInfo'])){echo "<button type='submit'>发表帖子</button>";}else{echo "您还没登陆，发帖<a href='/User/user/login'>请登录</a>";}</php>
                        </form>
                    </div>
                </div>
                    <include file="public:footer"/>
               
		<script type='text/javascript' src='/static/view/js/jquery-1.8.3.js'></script>
		<script type='text/javascript'>
                     function getPositions(){
                        var startPosition=endPosition=0;
                        var element=document.getElementById('selectable');
                        if(document.selection){
                            var range=document.selection.createRange();
                            var drange=range.duplicate();
                            drange.moveToElementText(element);
                            drange.setEndPoint('EndToEnd',range);
                            startPosition=drange.text.length-range.text.length;
                            endPosition=startPosition+range.text.length;//alert('ie');
                        }
                        else if(window.getSelection){
                            //firefox chrome safari
                            startPosition=element.selectionStart;
                            endPosition=element.selectionEnd;//alert(endPosition);
                        }
                        return {'start':startPosition,'end':endPosition};
                    }
			$(document).ready(function(){
                           
                               $('#btn_h_type').click(function(){
                                    CKEDITOR.replace( 'selectable', {
                                            uiColor: '#BDD7E3',
                                            toolbarCanCollapse:true,
                                            language :'zh-cn'
                                            //toolbarLocation :''
                                    });
                                    $('#btn').css('display','none');
                                    $('#btn_l_type').css('display','inline');
                                    $('#btn_h_type').css('display','none');
                                });
                                 $('#btn_l_type').click(function(){
                                    document.location.reload();
                                    $('#btn_l_type').css('display','none');
                                    $('#btn_h_type').css('display','inline');
                                });
                               /*格式化文本，给文本选中添加样式，例如斜体，粗体*/
                                $('#apply').click(function(){
                                    $('#container').html($('#selectable').val());
                                });
                                $('.btn').click(function(){
                                    var positions=getPositions();
                                    if(positions.start==positions.end){
                                        return false;
                                    }
                                    var tag=$(this).val();
                                    var textOnPage=$('#selectable').val();
                                    var startString=textOnPage.substr(0, positions.start);
                                    var targetString=textOnPage.substr(positions.start,positions.end-positions.start);
                                    var formattedString="<" + tag+">" + targetString + "</"+tag+">";
                                    var endString=textOnPage.substr(positions.end);//alert(endString+'||'+startString+'||'+formattedString);
                                    $("#selectable").val(startString + formattedString + endString);//alert($("#selectable").val());
                                });
                                /*格式化文本，给文本选中添加样式，例如斜体，粗体*/
                                $('.title').click(function(){
                                    $(this).next('div.container').slideToggle('fast');
                                });
                                $('#posts-submit').submit(function(){
                                    if($.trim($('#selectable').val())==''){
                                        //alert('回复内容不能为空');
                                        return false;
                                    }

                                });
                               
				
			});
		
		</script>
	</body>
</html>